package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TLangLibrary;
import com.ruoyi.system.service.ITLangLibraryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 语言记录Controller
 * 
 * @author ruoyi
 * @date 2024-04-19
 */
@RestController
@RequestMapping("/system/library")
public class TLangLibraryController extends BaseController
{
    @Autowired
    private ITLangLibraryService tLangLibraryService;

    /**
     * 查询语言记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:library:list')")
    @GetMapping("/list")
    public TableDataInfo list(TLangLibrary tLangLibrary)
    {
        startPage();
        List<TLangLibrary> list = tLangLibraryService.selectTLangLibraryList(tLangLibrary);
        return getDataTable(list);
    }

    /**
     * 导出语言记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:library:export')")
    @Log(title = "语言记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TLangLibrary tLangLibrary)
    {
        List<TLangLibrary> list = tLangLibraryService.selectTLangLibraryList(tLangLibrary);
        ExcelUtil<TLangLibrary> util = new ExcelUtil<TLangLibrary>(TLangLibrary.class);
        util.exportExcel(response, list, "语言记录数据");
    }

    /**
     * 获取语言记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:library:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tLangLibraryService.selectTLangLibraryById(id));
    }

    /**
     * 新增语言记录
     */
    @PreAuthorize("@ss.hasPermi('system:library:add')")
    @Log(title = "语言记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TLangLibrary tLangLibrary)
    {
        return toAjax(tLangLibraryService.insertTLangLibrary(tLangLibrary));
    }

    /**
     * 修改语言记录
     */
    @PreAuthorize("@ss.hasPermi('system:library:edit')")
    @Log(title = "语言记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TLangLibrary tLangLibrary)
    {
        return toAjax(tLangLibraryService.updateTLangLibrary(tLangLibrary));
    }

    /**
     * 删除语言记录
     */
    @PreAuthorize("@ss.hasPermi('system:library:remove')")
    @Log(title = "语言记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tLangLibraryService.deleteTLangLibraryByIds(ids));
    }
}
